import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Copyright © 2018胡建松. All rights reserved.
 *
 * @Package: PACKAGE_NAME
 * @author: hujiansong
 * @date: 2018/7/25 9:52
 * @version: V1.0
 */
public class InputUtil {


    public static List<List<String>> readFile() {
        String path = "F:\\Program\\qianniu\\StringApplicaion\\src\\young.txt";
        File file = new File(path);
        InputStream is = null;
        BufferedReader br = null;
        List<List<String>> trees = new ArrayList<>();
        try {

            is = new FileInputStream(file);
            br = new BufferedReader(new InputStreamReader(is));
            String str;
            StringBuffer sb = new StringBuffer();

            List<String> connections = null;
            while ((str = br.readLine()) != null) {
                try {
                    Integer.parseInt(str);
                    connections = new ArrayList<>();
                    trees.add(connections);
                } catch (NumberFormatException e) {
                    // station站点数不加入
                    connections.add(str);
                    System.out.println(str);
                }

            }

        } catch (IOException e) {
            System.out.println("读取航班信息出现异常~ \n" + e.getMessage());
        } finally {
            try {
                if (is != null) {
                    is.close();
                }

                if (br != null) {
                    br.close();
                }
            } catch (IOException e1) {
                System.out.println("读取航班信息出现异常~ \n" + e1.getMessage());
            }

        }
        return trees;
    }


}
